import {Http} from "../utils/http"
import {User} from "./user"

class Pk {
    constructor() {
    }

    /**
     * 创建PK
     * @param count PK题数
     * @returns {Promise<void>}
     */
    static async createPk(count) {
        return await Http.request({
            url: '/pks',
            data: {
                count
            },
            method: 'POST'
        })
    }

    /**
     * 更新左方选手pk答题情况
     * @param pkid
     * @param data
     * @returns {Promise<*>}
     */
    static async updateLeftPkDetail(pkid,data) {
        return await Http.request({
            url: `/pks/${pkid}/left`,
            data,
            method: 'PUT'
        })
    }

    /**
     * 更新右方选手pk答题情况
     * @param pkid
     * @param data
     * @returns {Promise<*>}
     */
    static async updateRightPkDetail(pkid,data) {
        console.log(pkid, data)
        return await Http.request({
            url: `/pks/${pkid}/right`,
            data,
            method: 'PUT'
        })
    }

    /**
     * 获取pk详情
     * @param pkid
     * @returns {Promise<*>}
     */
    static async getPkDetail(pkid) {
        return await Http.request({
            url: `/pks/${pkid}`
        })
    }

    /**
     * 加入右方PK
     * @param pkid
     * @returns {Promise<*>}
     */
    static async joinPkRight(pkid) {
        return await Http.request({
            url: `/pks/${pkid}/join_right`,
            method: 'PUT'
        })
    }

    static async destoryPk(pkid) {
        return await Http.request({
            url: `/pks/${pkid}`,
            method: 'DELETE'
        })
    }
}
export {
    Pk
}
